import request from "@/utils/request";
import type {
  SongListObj,
  getsongSheetObj,
  songSheeInf,
  CommentListObj,
} from "@/api/discoverMusic/model/ranking";
enum Api {
  getSongListUrl = "/toplist/detail",
  getsongSheetUrl = "/playlist/track/all",
  getsongSheeInfUrl = "/playlist/detail",
  getCommentListUrl = "/comment/playlist",
  sendingCommentUrl = "/comment",
  getLiSongsheetListUrl = "/artist/songs",
  getLisingleSongsheetUrl = "/song/url",

  // /?id=19723756
}
/**
 *
 * @returns
 */
export const getSongListApi = () => {
  return request.get<any, SongListObj>(Api.getSongListUrl);
  // return request.get<any, SongListArray>("/toplist/detail");
};

export const getsongSheetApi = (id: number, offset: number, limit: number) => {
  return request.get<any, getsongSheetObj>(Api.getsongSheetUrl, {
    params: {
      id,
      limit,
      offset,
    },
  });
  // return request.get<any, SongListArray>("/toplist/detail");
};

export const getsongSheeInfApi = (id: number) => {
  return request.get<any, songSheeInf>(Api.getsongSheeInfUrl, {
    params: {
      id,
    },
  });
  // return request.get<any, SongListArray>("/toplist/detail");
};

// 评论列表
export const getCommentListApi = (id: number, limit = 40) => {
  return request.get<any, CommentListObj>(Api.getCommentListUrl, {
    params: {
      id,
      limit,
    },
  });
  // return request.get<any, SongListArray>("/toplist/detail");
};

//发送评论;
export const sendingCommentApi = (
  t: number,
  type: number,
  threadId: string,
  content: string
) => {
  return request.post<any, CommentListObj>(
    Api.sendingCommentUrl,
    {},
    {
      params: {
        t,
        type,
        threadId,
        content,
      },
    }
  );
  // return request.get<any, SongListArray>("/toplist/detail");
};

// 歌曲列表
export const getLiSongsheetListApi = (id: number) => {
  return request.get<any, any>(Api.getLiSongsheetListUrl, {
    params: {
      id,
    },
  });
  // return request.get<any, SongListArray>("/toplist/detail");
};

// /song/url?id=1407551413 single
//  单个歌曲
export const getLisingleSongsheetApi = (id: number) => {
  return request.get<any, any>(Api.getLisingleSongsheetUrl, {
    params: {
      id,
    },
  });
  // return request.get<any, SongListArray>("/toplist/detail");
};
